﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.System.UserProfile;
using Bing_Map.Exceptions;
using Bing_Map.Model;

namespace Bing_Map
{
    public class AppController
    {

        public String WelcomeMessage 
        {
            get { return "Welcome " + this.UserName; }
        }

        private String userName;
        public String UserName
        {
            get { return this.userName; }
            set { this.userName = value; }
        }

        public AppController()
        {
            this.IdentifyUser();
        }

        private async void IdentifyUser()
        {          
            String name = await UserInformation.GetDisplayNameAsync();
            if (string.IsNullOrEmpty(name))
            {
                throw new LoginRequiredException("User must be logged with a passport account");
            }
            else
            {
                this.UserName = name;
            }
        }

        public String MapTitle
        {
            get { return "Near events"; }
        }

}
